/**
 * @program: LeetCode
 * @description: LeetCode : 55. 跳跃游戏
 * @author: WXY
 * @create: 2023-01-03 15:18
 * @Version 1.0
 **/
public class Num055_canJump {
    public static boolean canJump(int[] nums) {
        int maxRange = 0;
        int size = nums.length;
        for (int i = 0; i <= maxRange; i++) {
            maxRange = Math.max(maxRange, i + nums[i]);
            if (maxRange >= size) {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        int[] arr = {3, 2, 1, 0, 4};
        boolean b = canJump(arr);
        System.out.println(b);

    }
}
